package com.example.tianyutong.qanda.ui;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.FragmentActivity;

import com.example.tianyutong.qanda.R;

/**
 * 启动页面
 *
 * @author tianyutong
 */
public class LoadingActivity extends FragmentActivity {

    private Handler handler;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // 后台返回时可能启动这个页面 http://blog.csdn.net/jianiuqi/article/details/54091181
        if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
            finish();
            return;
        }//https://www.linuxidc.com/Linux/2014-06/103729.htm
        handler = new Handler();
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                startActivity(new Intent(LoadingActivity.this, MainActivity.class));//显式启动跳转主页面
                overridePendingTransition(R.anim.screen_zoom_in, R.anim.screen_zoom_out);//跳转动画
                finish();
            }
        }, 200);
    }

    @Override
    protected void onDestroy() {
        handler = null;
        super.onDestroy();
    }
}
